<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Th extends CI_Controller {

    function __construct() {

        @session_start();
        parent::__construct();
        $this->load->model('kaki/th_model','th_model');

    }

    public function TAT() {

        $client_id=$this->th_model->get_client();
        $d_fields=$this->th_model->get_demand_fields();
        $o_fields=$this->th_model->get_object_fields();

        $object_fields = array();
        $demand_fields = array();

        foreach ($d_fields as $f_name) {

            if( $f_name!='client_id'  AND $f_name!='head' AND $f_name!='broker'  AND $f_name!='ctime' 
                    AND $f_name!='dtime' AND $f_name!='mtime' AND $f_name!='front_man' AND $f_name!='status' 
                    AND $f_name!='ref_client_verify_code' AND $f_name!='demand_id' 
                    AND $f_name!='client_contact_id' 
                    AND $f_name!='point_count' AND $f_name!='shop_point_id'  AND $f_name!='owner' 
                    AND $f_name!='object_id'  AND $f_name!='client_id'  AND $f_name!='head' 
                    AND $f_name!='broker'  AND $f_name!='ctime' 
                    AND $f_name!='dtime' AND $f_name!='mtime' AND $f_name!='front_man' AND $f_name!='status' 
                    AND $f_name!='ref_client_verify_code' AND $f_name!='demand_id' 
                    AND $f_name!='client_contact_id' 
                    AND $f_name!='point_count' AND $f_name!='shop_point_id' AND $f_name!='owner' 
                    AND $f_name!='original_broker' AND $f_name!='remark' AND $f_name!='invalid_description' 
                    AND $f_name!='object_id' AND $f_name!='assigned_date'    
                    AND $f_name!='ref_client_verify_code' ){
                $demand_fields[] =  $f_name;
            }
        }


        foreach ($o_fields as $f_name) {
            if( $f_name!='client_id'  AND $f_name!='head' AND $f_name!='broker'  AND $f_name!='ctime' 
                    AND $f_name!='dtime' AND $f_name!='mtime' AND $f_name!='front_man' AND $f_name!='status' 
                    AND $f_name!='ref_client_verify_code' AND $f_name!='demand_id' 
                    AND $f_name!='client_contact_id' 
                    AND $f_name!='point_count' AND $f_name!='shop_point_id'  AND $f_name!='owner' 
                    AND $f_name!='object_id'  AND $f_name!='client_id'  AND $f_name!='head' 
                    AND $f_name!='broker'  AND $f_name!='ctime' 
                    AND $f_name!='dtime' AND $f_name!='mtime' AND $f_name!='front_man' AND $f_name!='status' 
                    AND $f_name!='ref_client_verify_code' AND $f_name!='demand_id' 
                    AND $f_name!='client_contact_id' 
                    AND $f_name!='point_count' AND $f_name!='shop_point_id' AND $f_name!='owner' 
                    AND $f_name!='original_broker' AND $f_name!='remark' AND $f_name!='invalid_description' 
                    AND $f_name!='object_id' AND $f_name!='assigned_date'    
                    AND $f_name!='ref_client_verify_code' ){

                $object_fields[] =  $f_name;

            }
        }

        $ppp=1;
        foreach ($object_fields as $key => $value) {

            if(1){

                //$data=array();
                $data[$value]=rand(1,999);
                //$p=$this->insert_obj_data(3);

                $this->th_model->insert_object($data);
            }

            $ppp++;
        }

        foreach ($demand_fields as $key => $value) {

            if(1){

                //$data=array();
                //$_rand_=rand(1,9);
                //$data[$value]=$_rand_;
                $data=$this->insert_obj_data(3);
                $this->th_model->insert_demand($data);

            }

        }
    }


    public function insert_obj_data( $count) {

            $data=array();
            for($c=1;$c<=$count ;$c++){

                $i=rand(1,10);

                switch ($i) {
                        case 1:
                            $data['building_area1']=rand(10,100);
                            $data['building_area2']=rand(200,3999);
                            break;

                        case 2:
                            $data['indoor_area1']=rand(10,100);
                            $data['indoor_area2']=rand(200,3999);
                            break;

                        case 3:
                            $data['land_area1']=rand(10,100);
                            $data['land_area2']=rand(200,3999);
                            break;

                        case 4:
                            $data['key_areas1']=rand(10,100);
                            $data['key_areas2']=rand(200,3999);
                            break;    

                        case 5:
                            $data['specify_building1']=rand(10,100);
                            $data['specify_building2']=rand(200,3999);
                            break; 

                        case 6:
                            $data['sections1']=rand(10,100);
                            $data['sections2']=rand(200,3999);
                            break;            

                        case 7:
                            $data['administrative_area1']=rand(10,100);
                            $data['administrative_area2']=rand(200,3999);
                            break;    
                        case 8:
                            $data['total_budget1']=rand(10,100);
                            $data['total_budget2']=rand(200,3999);
                            break;    
                        case 9:
                            $data['administrative_area1']=rand(10,100);
                            $data['administrative_area2']=rand(200,3999);
                            break;  

                        case 10:
                            $data['administrative_area1']=rand(10,100);
                            $data['administrative_area2']=rand(200,3999);
                            break;                
                    }
            }

        return $data;        

    }


    public function del_o_d() {

        //echo 'qweqweqqqq';

        $this->th_model->del_demand();
        $this->th_model->del_object();

    }
	
	

}
